# Call API and show help
# PowerShell Script

$ApiUrl = "http://120.27.155.222:9999/api/message/send-test"

Write-Host "=====================================================================================================" -ForegroundColor Cyan
Write-Host "Shumei SDK - API Caller" -ForegroundColor Yellow
Write-Host "=====================================================================================================" -ForegroundColor Cyan
Write-Host ""

Write-Host "[Step 1/2] Calling API..." -ForegroundColor Green
Write-Host "  URL: $ApiUrl" -ForegroundColor Gray
Write-Host ""

try {
    $response = Invoke-RestMethod -Uri $ApiUrl -Method GET -ErrorAction Stop
    
    Write-Host "Success!" -ForegroundColor Green
    Write-Host ""
    
    Write-Host "[Step 2/2] API Response:" -ForegroundColor Green
    Write-Host "-----------------------------------------------------------------------------------------------------" -ForegroundColor Gray
    $response | ConvertTo-Json -Depth 10 | Write-Host
    Write-Host "-----------------------------------------------------------------------------------------------------" -ForegroundColor Gray
    Write-Host ""
    
    Write-Host "Encrypted Fields:" -ForegroundColor Cyan
    Write-Host "  dev      : $($response.dev)"
    Write-Host "  last_box : $($response.last_box)"
    Write-Host ""
    
    Write-Host "=====================================================================================================" -ForegroundColor Red
    Write-Host "IMPORTANT: You need to capture the AES key!" -ForegroundColor Red
    Write-Host "=====================================================================================================" -ForegroundColor Red
    Write-Host ""
    Write-Host "How to get the AES key:" -ForegroundColor Yellow
    Write-Host ""
    Write-Host "Option 1: Hook server-side Java process (requires SSH access)" -ForegroundColor Cyan
    Write-Host "  See: HookRemoteServer.md for details"
    Write-Host ""
    Write-Host "Option 2: Use Android emulator" -ForegroundColor Cyan
    Write-Host "  1. Start frida-server on emulator"
    Write-Host "  2. Run: frida -U -f com.mcdonalds.gma.cn -l hook_complete_flow.js"
    Write-Host "  3. Trigger SDK in the app"
    Write-Host "  4. Copy the key from Frida output"
    Write-Host ""
    Write-Host "After getting the key, run:" -ForegroundColor Green
    Write-Host "  java DecryptWithCapturedKey" -ForegroundColor White
    Write-Host ""
    
} catch {
    Write-Host "API call failed!" -ForegroundColor Red
    Write-Host "Error: $_" -ForegroundColor Red
}

Write-Host "Done!" -ForegroundColor Green


